package com.example.feign.fallback;

import com.example.entity.Product;
import com.example.feign.ProductFeignClient;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 远程调用ProductFeignClient失败后才会走ProductFeignFallback的逻辑
 */
@Component
public class ProductFeignFallback implements ProductFeignClient {
    @Override
    public Product getProductById(Long id) {
        System.out.println("兜底回调");
        Product product = new Product();
        product.setId(id);
        product.setPrice(new BigDecimal("0"));
        product.setProductName("未知");
        product.setNum(0);
        return product;
    }
}
